<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div style="width:100%;text-align: center;font-size:18px;height: 40px;margin-top: 20px;">
当前学期:<span style="font-size:20px;" id="currentSemesterName">${result.semesterName}</span>(<span id="sbeginDate" style="font-size: 19px;"><fmt:formatDate pattern="yyyy-MM-dd" value="${result.startDate }" /></span> ~<span id="sendDate" style="font-size: 19px;"><fmt:formatDate pattern="yyyy-MM-dd" value="${result.endDate }" /></span> )
</div>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="dictMajorList" checkbox="true" fitColumns="true" 
  	 title="学期信息管理" actionUrl="semesterInfoController.do?datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="主键"  field="currentFlag"  hidden="true"  queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="学期名称"  field="semesterName"  hidden="false"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="开始日期"  field="startDate" formatter="yyyy-MM-dd" hidden="false"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="结束日期"  field="endDate" formatter="yyyy-MM-dd" hidden="false"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="是否删除"  field="isDeleted"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgFunOpt  funname="editItemDetail({'编辑'},{'semesterInfoController.do?goUpdate'},id,{'570'},{'280'})" title="编辑"  />  
   <t:dgDelOpt title="删除" url="semesterInfoController.do?doDel&id={id}" exp="currentFlag#eq#0" />
   <t:dgFunOpt title="设置当前学期" funname="setCurrentFlag(id)" />
   <t:dgFunOpt title="设置下个学期" funname="setNextFlag(id)" />
   <t:dgToolBar title="创建新学期" icon="icon-add" url="semesterInfoController.do?goAdd" funname="add" height="280" width="570"></t:dgToolBar>
    <t:dgToolBar title="批量删除"  icon="icon-remove" url="semesterInfoController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>
  <script type="text/javascript">
  
  function setCurrentFlag(id,index){

		$.dialog.confirm('确定将该学期设置为当前学期吗?', function(r) {
			   if (r) { 
					$.ajax({
						url : 'semesterInfoController.do?setCurrentFlag&id='+id+"&rec",
						type : 'post', 
						cache : false,
						success : function(data) {
							var d = $.parseJSON(data);
							if (d.success) {
								var msg = d.msg;
								tip(msg);
								reloadTable(); 
								 var row =  $('#dictMajorList').datagrid('getRows');
								$("#currentSemesterName").html("");
								$("#currentSemesterName").html(row[index].semesterName);
								$("#sbeginDate").html("");
								$("#sbeginDate").html(row[index].startDate.substring(0,10));
								$("#sendDate").html("");
								$("#sendDate").html(row[index].endDate.substring(0,10));
							}else{
								tip(d.msg);
							}
						}
					});
				}
			}); 
	}
  function setNextFlag(id){
		$.dialog.confirm('确定将该学期设置为下学期吗?', function(r) {
			   if (r) { 
					$.ajax({
						url : 'semesterInfoController.do?setNextFlag&id='+id+"&rec",
						type : 'post', 
						cache : false,
						success : function(data) {
							var d = $.parseJSON(data);
							if (d.success) {
								var msg = d.msg;
								tip(msg);
								reloadTable(); 
							}else{
								tip(d.msg);
							}
						}
					});
				}
			}); 
	}
  
  </script>